﻿<!DOCTYPE html>
<html>
<head>
    <title>CGI</title>
</head>
<body>
    <h1>Our Page</h1>
    <script>
        //some functions that exist in Object.prototype

        //01
        //hasOwnProperty function exist in Object.prototype and
        //here directly exist in project object itself

        'use strict';
        var project = {
            name: 'Top Secret Project',
            dueDate: '1/1/2016'
        };
        console.log(project.hasOwnProperty('name'));

        //toString function is not directly belongs to project object
        'use strict';
        var project = {
            name: 'Top Secret Project',
            dueDate: '1/1/2016'
        };
        console.log(project.hasOwnProperty('toString'));

        //Object.prototype is the base object for project
        console.log(project.__proto__.hasOwnProperty('toString'));


        //02
        //project is prototype for secretProject
        /*
        var project = {
            securityLevel: 2
        };
        var secretProject = Object.create(project);
        console.log(project.isPrototypeOf(secretProject));
        //walk the prototype chain
        console.log(Object.prototype.isPrototypeOf(secretProject));
        //Object.prototype is same as project.__proto__
        console.log(project.__proto__.isPrototypeOf(secretProject));
        */

        //03
        //"in" operators check the property exist in object or not
        /*
        var project = {
            securityLevel: 2
        };
        var secretProject = Object.create(project);
        console.log("securityLevel" in secretProject);
        //it also walk through prototype
        console.log("toString" in secretProject);
        //Object.prototype doesn't know about secretProject
        console.log("securityLevel" in Object.prototype);
        */
    </script>
</body>
</html>